LinuxQMISDK  SLQS04.00.27
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
common.h
Go to the documentation of this file.
1 
6 #ifndef __COMMON_H
7 #define __COMMON_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #include <stdint.h>
14 #include "switype_256bit.h"
15 #define SDU_HDR_LEN (3)
16 #define MINREQBKLEN (2048)
17 #define MSGID_AND_LEN (4)
18 #define MSGID_DONT_CARE (0xffff)
19 
20 #ifndef UNUSEDPARAM
21 #define UNUSEDPARAM( x ) (void)x
22 #endif
23 
24 #define DEAULT_LOC_TIMEOUT_IN_SEC 2
25 #define SDK_VALIDATE_INPUT_PACK_PARAM(pCtx, pBuf, pLen ) \
26  if ((pCtx == NULL) || (pBuf == NULL) || (pLen == NULL) ) \
27  {\
28  liteqmi_log(eLOG_DEBUG,"[ pack] %s parameter NULL\n",__func__); \
29  return eQCWWAN_ERR_INVALID_ARG; \
30  }
31 
32 #define SDK_VALIDATE_INPUT_PACK_PARAM_AND_FILL_XID(pCtx, pBuf, pLen ) \
33  if ((pCtx == NULL) || (pBuf == NULL) || (pLen == NULL) ) \
34  {\
35  liteqmi_log(eLOG_DEBUG,"[ pack] %s parameter NULL\n",__func__); \
36  return eQCWWAN_ERR_INVALID_ARG; \
37  } \
38  if (pCtx->xid == 0) \
39  return eQCWWAN_ERR_INVALID_XID; \
40  pBuf[0] = eREQ; \
41  pBuf[1] = pCtx->xid & 0xff; \
42  pBuf[2] = pCtx->xid >> 8;
43 
44 #define SDK_VALIDATE_INPUT_UNPACK_PARAM(pResp, respLen, pOutput ) \
45  if ((pResp == NULL) || (respLen == 0) || (pOutput == NULL) ) \
46  {\
47  liteqmi_log(eLOG_DEBUG,"[ unpack] %s parameter NULL or invalid\n",__func__); \
48  return eQCWWAN_ERR_INVALID_ARG; \
49  }
50 
51 //typedef void (* logger)(uint8_t lvl, const char* buff);
52 
53 extern logger *glog;
54 extern uint8_t gloglvl;
55 
64 };
65 
70 {
71  eTIMEOUT_2_S = 2000,
72  eTIMEOUT_5_S = 5000,
73  eTIMEOUT_8_S = 8000,
74  eTIMEOUT_10_S = 10000,
75  eTIMEOUT_20_S = 20000,
76  eTIMEOUT_30_S = 30000,
77  eTIMEOUT_60_S = 60000,
78  eTIMEOUT_300_S = 300000,
80 };
81 
85 enum eQMI_SVC{
86  eCTL=0,
89  eNAS=3,
91  eSMS=5,
92  ePDS=0x06,
93  eVOICE=0x09,
94  eCAT=0x0A,
95  eUIM=0x0B,
96  eLOC=0x10,
97  eSAR=0x11,
98  eIMS=0x12, // 012 IMS Service
99  eTMD=0x18,
100  eWDA=0x1A,
101  eIMSA=0x21,
102  eDSD=0x2A, //DSD is assigned QMI service type 0x2A
103  eRMS=225,
104  eSWIOMA=240,
105  eAUDIO=241,
106  eSWIM2MCMD=243, // 0xF3 SWI M2M general commands
107  eSWIM2MCMD_AVC2=0xfd, // 0xFD SWI M2M general commands
109  eSWIAUDIO= 245, // 245 Swi Audio service
110  eSWILOC=246,
112 };
113 
117 enum msgtype{
118  eREQ=0,
119  eRSP=2,
121 };
122 
130 typedef struct{
131  uint16_t xid;
132  int timeout;
133  uint16_t msgid;
134  uint8_t svc;
135 } pack_qmi_t;
136 
143 typedef struct{
144  enum msgtype type;
145  uint16_t msgid;
146  uint16_t xid;
147 } unpack_qmi_t;
148 
149 uint16_t helper_get_xid(uint8_t *qmi_resp);
150 
151 uint16_t helper_get_error_code(uint8_t *qmi_resp);
152 char* helper_get_error_reason(uint16_t retVal);
153 
162 const char* helper_get_resp_ctx(
163  uint8_t svc,
164  uint8_t *pbuf,
165  uint32_t len,
166  unpack_qmi_t *pCtx
167  );
168 
176 const char* helper_get_req_str(
177  uint8_t svc,
178  uint8_t *req,
179  uint32_t len
180  );
181 
185 unsigned unpack_result_code_only(
186  uint8_t *pMdmResp);
187 
191 int helper_set_log_func(logger *func);
192 
193 void liteqmi_log(
194  uint8_t lvl,
195  const char* fmt, ...
196  );
197 
201 int helper_set_log_lvl(uint8_t lvl);
202 
203 //internal helper for pack/unpack function
204 void fill_sdu_hdr(
205  pack_qmi_t *pCtx,
206  uint8_t *pReqBuf
207  );
208 
209 void fill_pack_ctx(
210  pack_qmi_t *pCtx,
211  uint8_t *pReqBuf,
212  uint16_t *pLen,
213  uint8_t svc,
214  int timeout
215  );
219 char* get_version();
220 
224 char* liteqmi_GetVersion();
225 
233  uint8_t *encoded_str,
234  uint8_t encoded_len,
235  uint8_t *decoded_str
236  );
237 
252 int helper_isBootLoader_DebugEnabled(const char* szPath, const char* pQsn );
253 
254 #define SWI_INIT_UNPACK_RESULT_VALUE {0, SWI_UINT256_INT_VALUE}
255 
260 typedef struct
261 {
262 uint16_t Tlvresult;
265 
266 #ifdef __cplusplus
267 } /* extern "C" { */
268 #endif
269 
270 #endif
void fill_pack_ctx(pack_qmi_t *pCtx, uint8_t *pReqBuf, uint16_t *pLen, uint8_t svc, int timeout)
Definition: common.h:92
int timeout
Definition: common.h:132
Definition: common.h:97
logger * glog
Definition: common.h:89
Definition: common.h:88
char * helper_get_error_reason(uint16_t retVal)
Definition: common.h:98
const char * helper_get_resp_ctx(uint8_t svc, uint8_t *pbuf, uint32_t len, unpack_qmi_t *pCtx)
int helper_set_log_func(logger *func)
Definition: common.h:63
uint16_t Tlvresult
Definition: common.h:262
Definition: common.h:100
Definition: common.h:71
Definition: common.h:99
Definition: common.h:72
int helper_set_log_lvl(uint8_t lvl)
Definition: common.h:120
Definition: common.h:94
Definition: common.h:95
Definition: common.h:74
Definition: common.h:79
Definition: common.h:118
Definition: common.h:110
Definition: common.h:104
Definition: common.h:76
uint16_t helper_get_xid(uint8_t *qmi_resp)
Definition: common.h:62
Definition: common.h:260
Definition: common.h:91
Definition: common.h:93
Definition: common.h:90
eTimeout
Definition: common.h:69
uint16_t xid
Definition: common.h:146
uint16_t xid
Definition: common.h:131
Definition: common.h:86
void liteqmi_log(uint8_t lvl, const char *fmt,...)
uint16_t msgid
Definition: common.h:133
Definition: common.h:73
Definition: common.h:105
const char * helper_get_req_str(uint8_t svc, uint8_t *req, uint32_t len)
int helper_isBootLoader_DebugEnabled(const char *szPath, const char *pQsn)
Definition: common.h:87
void liteqmi_helper_decode7bitAsciiEncString(uint8_t *encoded_str, uint8_t encoded_len, uint8_t *decoded_str)
Definition: common.h:60
char * liteqmi_GetVersion()
uint16_t helper_get_error_code(uint8_t *qmi_resp)
Definition: common.h:109
Definition: common.h:102
Definition: common.h:75
void fill_sdu_hdr(pack_qmi_t *pCtx, uint8_t *pReqBuf)
Definition: common.h:103
Definition: common.h:108
Definition: common.h:143
uint8_t svc
Definition: common.h:134
Definition: common.h:78
Definition: common.h:106
char * get_version()
uint16_t msgid
Definition: common.h:145
unsigned unpack_result_code_only(uint8_t *pMdmResp)
Definition: common.h:101
void(* logger)(uint8_t lvl, const char *buff)
Definition: switype_256bit.h:52
Definition: common.h:130
Definition: common.h:107
Definition: switype_256bit.h:15
Definition: common.h:61
Definition: common.h:111
uint8_t gloglvl
Definition: common.h:77
eLOG_LEVEL
Definition: common.h:59
eQMI_SVC
Definition: common.h:85
swi_uint256_t ParamPresenceMask
Definition: common.h:263
Definition: common.h:96
msgtype
Definition: common.h:117
Definition: common.h:119

Copyright (c) 2011-2015 Sierra Wireless, Inc. All rights reserved